function routeConvert(routes) {
  // 简单检查是否是可以处理的数据
  if (!(routes instanceof Array)) {
    return false
  }
  const componentRouters = []
  routes.forEach((element) => {
    if (element.menuType === 'C' || element.menuType === 'S') {
      let path = element.url
      if (element.menuType === 'S') {
        let i = path.indexOf('/:')
        if (i > 0) {
          path = path.substring(0, i)
        }
      }
      const fmRouter = {
        path: element.url,
        // component(resolve) {
        //   // 拼出相对路径，由于component无法识别变量
        //   require(['@/components' + path], resolve)
        // },
        component: () => import(`../components${path}`),
        name: element.perms,
        meta: {
          title: element.menuName
        }
      }
      componentRouters.push(fmRouter)
    }
  })
  return componentRouters
}

export default routeConvert
